<?php
namespace app\admin\model;

use think\Model;
class Links extends Model
{
	public function getLinks($lid)
	{   
		if($lid !=0){
			$where['lid']=$lid;
			$get_links = $this->where($where)->select();
		 }else{
			 $get_links = $this->select();
		 }
	
	 return $get_links;
	}
	
	public function addLinks()
	{
		$data['name']=$_POST['name'];
		$data['lid']=$_POST['lid'];
        if(I('?post.logo'))
            $data['logo']=I('post.logo');
		$data['links']=$_POST['links'];
		$data['creat_time']=time();
		$add_links = $this->add($data);
		return $add_links;
	}
	
	public function delLinks($id)
	{
		$del_links = $this->delete($id);
		return $del_links;
	}
	
	public function getInfo($id)
	{
		$get_info = $this->find($id);
		return $get_info;
	}
	
	public function postEdit()
	{
		$where['id'] = I('post.id');
		$data['name']= I('post.name');
		$data['logo']= I('post.logo');
		$data['links']= I('post.links');
		$post_edit = $this->where($where)->save($data);
		return $post_edit;
		
	}
	
	public function selectLinksType()
	{
		$type = M('linktype')->select();
		return $type;
	}
	
	
	//添加linktype,考虑简单就直接不写新的模型
	public function linkType()
	{
		$linktype = M('linktype')->select();
		return $linktype;
	}
	
	public function lid()
	{
		$data['name']=I('post.name');
		$data['type']=I('post.type');
		$lid = M('linktype')->add($data);
		return $lid;
	}
	
	public function getLidInfo($id)
	{
		$get_info = M('linktype')->find($id);
		return $get_info;
	}
    public function lidDel($id){
		$del = M('linktype')->delete($id);
		return $del;
	}
	
	public function postLidEdit($id)
	{

		$where['id']=$id;
		$data['name']=I('post.name');
		$data['type']=I('post.type');
		$edit = M('linktype')->where($where)->save($data);
		return $edit;
	}
	
	public function listOrder($listorder,$listorder_id)
	{
		$data['listorder']=$listorder;
		$list_order = $this->where('id='.$listorder_id)->save($data);
	}
	
	
	
	
	
	
	
}
